package com.itheima.controller;

import com.itheima.health.entity.QueryPageBean;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.CheckItem;
//import com.itheima.health.pojo.User22;
import com.itheima.health.service.CheckItemService;
import io.swagger.annotations.*;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: health_paret
 * @description:
 * @author: Mr.Wang
 * @create: 2020-11-03 21:45hahahhahahah78910
 **/
@RestController
//ssss
@Api(tags = "传智健康-检查项接口文档")
public class AppoWeb {
    @Reference
    private CheckItemService checkItemService;


    //前端检查项进行删除数据 进行逻辑删除
    @DeleteMapping("checkitem/deleteCheckitemByid/{id}")
    @ApiOperation(value = "检查项列表删除", notes = "通过前端传来的检查项id对检查项进行删除")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "当前检查项的id",required = true,paramType = "form",dataType = "int")
    })
    public Result delete(@PathVariable int id) {
        System.out.println("id = " + id);
        Boolean delete = checkItemService.delete(id);
        return new Result(delete, "保存成功");
    }

    //前端发过来的添加用户请求以及进行用户的修改
    @PostMapping("checkitem/add")
    public Result add(@RequestBody CheckItem checkItem) {
        return new Result(true, "保存成功", checkItemService.add(checkItem));
    }

    //分页进行查找所有用户
    @ApiOperation(value = "检查项列表查询", notes = "根据客户端的相应，完成检查项所有信息的列表分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage", value = "当前分页页码", required = true, paramType = "form", dataType = "Integer"),
            @ApiImplicitParam(name = "pageSize", value = "每页显示记录数", required = true, paramType = "form", dataType = "Integer"),
            @ApiImplicitParam(name = "queryString", value = "查询条件", required = false, paramType = "form", dataType = "String")
    })
    @ApiResponses({
            @ApiResponse(code = 400, message = "请求参数没填好"),
            @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")
    })
    @PostMapping("checkitem/findAll")
    public Result findPage(@RequestBody QueryPageBean queryPageBean) {
        return new Result(true, "正确", checkItemService.findPage(queryPageBean));
    }
}
